package com.squirrel.facade;

import com.squirrel.service.CreateDeleteSql;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 对外提供sql删除方法
 *
 * @author wangyan
 */
public class Delete implements SqlOperate {

    private CreateDeleteSql createSQL;

    public Delete() {
        this.createSQL = new CreateDeleteSql();
    }

    public CreateDeleteSql getCreateDeleteSql() {
        return this.createSQL;
    }

    public final Delete from(String tableName) {
        createSQL.setQueryTable(tableName);
        return this;
    }

    public Delete where(String field, String condition, Long value) {
        createSQL.setWhere(field, condition, value);
        return this;
    }

    public Delete where(String field, String condition, String value) {
        createSQL.setWhere(field, condition, value);
        return this;
    }

    public Delete where(String field, String condition, LocalDateTime value) {
        createSQL.setWhere(field, condition, value);
        return this;
    }

    public Delete where(String field, String condition, List<Object> valueList) {
        createSQL.setWhere(field, condition, valueList);
        return this;
    }

    public Delete where(String field, String condition, Object value) {
        createSQL.setWhere(field, condition, value);
        return this;
    }

    public final Delete and(String field, String condition, String value) {
        createSQL.setAnd(field, condition, value);
        return this;
    }

    public final Delete and(String field, String condition, Object value) {
        createSQL.setAnd(field, condition, value);
        return this;
    }

    public void foreach(String field, String condition, String value) {
        createSQL.setForeach(field, condition, value);
    }

    public final Delete and(String field, String condition, long value) {
        createSQL.setAnd(field, condition, value);
        return this;
    }

    public final Delete and(String field, String condition, LocalDate value) {
        createSQL.setAnd(field, condition, value);
        return this;
    }

    public final Delete and(String field, String condition, LocalDateTime value) {
        createSQL.setAnd(field, condition, value);
        return this;
    }

    public final Delete and(String field, String condition, List<Object> valueList) {
        createSQL.setAnd(field, condition, valueList);
        return this;
    }
}
